<?php
namespace Callback\Controller;

use Think\Log;

class OssController extends BaseController
{
    private $logFile;

    public function _initialize()
    {
        $this->logFile = $logFile = LOG_PATH . 'Callback/' . date('Y-m-d') . '_oss.log';
    }

    /**
     * 自动提取封面回调
     *
     * @return void
     */
    public function upload()
    {
        $body = file_get_contents('php://input');
        Log::write($body, Log::INFO, '', $this->logFile);
         $xml = file_get_contents('php://input');
         $jsonObj = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);

         Log::write($jsonObj->Message, Log::INFO, '', $this->logFile);
         $message = json_decode($jsonObj->Message, true);
         if ($message['Name'] === 'activityEnd') {
             $mediaId = $message['MediaWorkflowExecution']['MediaId'];
             D('Helper/Media')->fill($mediaId);
         }
     }
    }

}
